package demo;

class Teacher implements Cloneable{
    public String name;


    @Override
    public String toString() {
        return "Teacher{" +
                "name='" + name + '\'' +
                '}';
    }

    @Override
    protected Object clone() throws CloneNotSupportedException {
        return super.clone();
    }
}

public class Test2 {
    public static void main(String[] args ) throws CloneNotSupportedException{
        Teacher teacher1 = new Teacher();
        teacher1.name = "松哥";
        Teacher teacher2 = (Teacher)teacher1.clone();
        System.out.println(teacher1);
        System.out.println(teacher2);

    }
}
